package com.ruleengine.db.model;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@TableName("rule")
public class Rule {

    @TableId(type = IdType.AUTO)
    private Long id;

    private String tenantId;

    private String rulechainId;

    private String ruleId;

    private RuleType type;

    private String args;

//    @Builder.Default
//    private String errorHandleArgs = JsonUtils.toJson(Collections.emptyList());

    @Version
    private Integer resourceVersion;

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @Builder.Default
    @TableLogic(value = "0", delval = "1")
    private RuleStatus status = RuleStatus.NORMAL;

}
